<%@ page import="com.lms.utils.GetCategoryUtil" %>
<%@ page import="com.lms.pojo.Category" %>
<%@ page import="java.util.*" %><%--
  Created by IntelliJ IDEA.
  User: hsy
  Date: 2023/5/30
  Time: 16:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%--共同侧边栏--%>
<%@ include file="sidebar.jsp" %>
<head>

</head>

<link rel="stylesheet" type="text/css" href="css/bookModify.css">

<body>
<%--
  <a href="<%=request.getContextPath()%>/modify.jsp?bookId=<%=book.getBookID()%>&title=<%=book.getTitle()%>&author=<%=book.getAuthor()%>&publisher=<%=book.getPublisher()%>&categoryName=<%=book.getCategoryName()%>&stockQuantity=<%=book.getStockQuantity()%>">修改</a>
  --%>
<%
  //调用工具类的方法，查所有的category返回到list集合中
  List<Category> categoryList = GetCategoryUtil.getCategoryList();
  int bookId = Integer.parseInt(request.getParameter("bookId"));
  String title = request.getParameter("title");
  String author = request.getParameter("author");
  String publisher = request.getParameter("publisher");
  String categoryName = request.getParameter("categoryName");
  int stockQuantity = Integer.parseInt(request.getParameter("stockQuantity"));
%>
<h2>
  <span>修</span>改<span>图书信息</span>
</h2>
<form action="bookModify" method="get">
  <label>图书id:</label>
  <input type="number" name="bookId" value="<%=bookId%>" readonly>
  <label>图书名称:</label>
  <input type="text" name="title" required="true" value="<%=title%>">
  <label>作者:</label>
  <input type="text" name="author" required="true" value="<%=author%>">
  <label>出版社:</label>
  <input type="text" name="publisher" required="true" value="<%=publisher%>">
  <label>图书类型:</label>
  <%--    动态展示图书类型--%>
  <select name="categoryID" required="true">
    <%--      <option value="1">小说</option>--%>
    <% for (Category c : categoryList) { %>
    <option value="<%= c.getCategoryId()%>"
            <% if (categoryName.equals(c.getCategoryName())) { %> selected<% } %>>
      <%= c.getCategoryName() %>
    </option>
    <% }%>
  </select>
  <label>库存:</label>
  <input type="number" name="stockQuantity" min="1" max="200" step="1" required="true" value="<%=stockQuantity%>">
  <input type="submit" value="修改"/>
</form>
</body>
</html>
